<template>
  <div>
    <el-input
      v-model="dataDictionaryName"
      disabled
    >
      <el-button slot="append" icon="el-icon-s-grid" @click="openModal" />
    </el-input>

    <dataDictionary-modal
      ref="dataDictionaryModel"
      @ok="handleOK"
    />
  </div>
</template>

<script>
import DataDictionaryModal from './DataDictionaryModal'
export default {
  name: 'DataDictionarySelect',
  components: {
    DataDictionaryModal
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    width: {
      type: Number,
      default: 500,
      required: false
    },
    value: {
      type: String,
      default: '',
      required: false
    },
    name: {
      type: String,
      default: '',
      required: false
    },
    disabled: {
      type: Boolean,
      required: false,
      default: false
    }

  },
  data() {
    return {
      visible: false,
      dataDictionaryName: ''
    }
  },
  watch: {
    value: {
      immediate: true,
      handler: 'handleValue'
    }
  },
  methods: {
    openModal() {
      this.$refs.dataDictionaryModel.show()
    },
    handleValue() {
      this.dataDictionaryName = this.name
    },
    handleOK(value, name) {
      this.$emit('changeSelect', value, name)
    }
  }
}
</script>

<style scoped>

</style>
